package longrise.phone.com.bjjt_jyb.myaccident;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.FormParameter;
import com.longrise.android.LFView;

import longrise.phone.com.bjjt_jyb.R;
import longrise.phone.com.bjjt_jyb.Utils.CommontUtils;


/**
 * 我的信息
 */
public class AccidentMyView extends LFView {

    private Context mContext;

    private View mView;

    private EntityBean baseBean;

    private LinearLayout playBtn;

    private ImageView animIV;//录音动画
    private String issingle;

    public AccidentMyView(Context context, EntityBean bean,String issingle) {
        super(context);
        this.mContext = context;
        this.baseBean = bean;
        this.issingle=issingle;
    }

    @Override
    public FormParameter getFormParameter() {
        FormParameter form = new FormParameter();
        form.setShowtitle(false);
        return form;
    }

    @Override
    public View getView() {
        return mView;
    }

    @Override
    public void init() {
        if (null == mContext) {
            return;
        }
        mView = LayoutInflater.from(mContext).inflate(R.layout.view_accidentmy, null);
        if (mView == null) {
            return;
        }
        //标题栏
        TextView titleTV = (TextView) mView.findViewById(R.id.tv_title);
        TextView tv_new6 = (TextView) mView.findViewById(R.id.tv_new6);
        if (TextUtils.equals("0", issingle)){
            titleTV.setText("单车事故信息");
        }else {
            titleTV.setText(R.string.accident_my_info);
        }
        if(TextUtils.equals("11", issingle)||TextUtils.equals("10", issingle)){
            tv_new6.setText("车辆品牌");
        }
        mView.findViewById(R.id.hn_btn_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                closeForm();
                OnDestroy();
            }
        });
        //录音信息
        playBtn = (LinearLayout) mView.findViewById(R.id.amy_btn_play);
        animIV = (ImageView) mView.findViewById(R.id.amy_iv_anim);
        TextView timeTV = (TextView) mView.findViewById(R.id.amy_tv_time);

        //车牌号
        TextView carnumTV = (TextView) mView.findViewById(R.id.amy_tv_carnum);
        //当事人
        TextView pesronTV = (TextView) mView.findViewById(R.id.amy_tv_person);
        //当事人
        TextView dutyTV = (TextView) mView.findViewById(R.id.amy_tv_duty);

        TextView my_tv_phone = (TextView) mView.findViewById(R.id.my_tv_phone);

        setListener(true);

        carnumTV.setText(baseBean.getString("casecarno"));
        pesronTV.setText(baseBean.getString("carownname"));
        my_tv_phone.setText(baseBean.getString("carownphone"));
        dutyTV.setText(CommontUtils.getDutyStr(baseBean.getString("dutytype")));
    }

    public void setListener(boolean flag) {
        if (null != playBtn) {
            if (!flag) {
                playBtn.setOnClickListener(null);
                return;
            }
//            playBtn.setOnClickListener(new RecordPlayListener(mContext, animIV, null));
        }
    }

    @Override
    public void refresh() {

    }

    @Override
    public void refreshByTime() {

    }

    @Override
    public void OnDestroy() {
        super.OnDestroy();
        setListener(false);
        mView = null;
        animIV = null;
    }
}
